<?php $this->Html->addCrumb('Payment Methods'); ?>
<div class="global-title"><?php __('Manage Payment Methods'); ?></div>
<?php echo $this->Session->flash(); ?>
    <table cellspacing="0" class="check-out-table">
		<thead>
            <tr>
                <th width="50" bgcolor="#ccc">SL</th>
                <th width="120" bgcolor="#ccc">Method Name</th>
                <th width="60" bgcolor="#ccc" style="text-align: center;">Actions</th>
                <th width="60" bgcolor="#ccc" style="text-align: center;">Status</th>
			</tr>
        </thead>
        <tbody>
			<?php
			$i = 0;
			if($paymentmethods){
			
			foreach ($paymentmethods as $paymentmethod):	
				$i++;
			?>
			<tr>
				<td class="alt"><?php echo $i; ?></td>
				<td class="alt"><?php echo $paymentmethod['Paymentmethod']['methodname']; ?></td>
				<td align="center" class="alt">
					<a href="javascript:void(0);" controller="paymentmethods" action="edit" title="Edit" ElmID="<?php echo $paymentmethod['Paymentmethod']['id']; ?>" onclick='showPop(this)'>
						<?php echo $this->Html->image("edit_gray.png", array("alt" => "Edit", 'border' => '0')); ?>
					</a>
				</td>
				<td align="center" class="alt">
					 <?php
					if($paymentmethod['Paymentmethod']['status']==1){
					?>
					<div id="status<?php echo $paymentmethod['Paymentmethod']['id']; ?>">
					<label>
					<input type="checkbox" checked="checked" name="isactive" onclick="return inactive('<?php echo $paymentmethod['Paymentmethod']['id']; ?>')"></label><div  style="display: inline;">&nbsp;Active</div></div>
					<?php
					}else{
					?>
					<div id="status<?php echo $paymentmethod['Paymentmethod']['id']; ?>">
					<label>
					<input type="checkbox" name="isactive" onclick="return active('<?php echo $paymentmethod['Paymentmethod']['id']; ?>')"></label><div style="display: inline;">&nbsp;Inactive</div></div>
					<?php
					}
					?>
				</td>
			</tr>
           
	<?php endforeach;}else{ ?>
			<tr><td colspan="4"><h3>No Payment Methods define</h3></td></tr>
	<?php } ?>
        <tbody>
    </table>
            

<style type="text/css">
td p span{color:#00B050;}
td.vendor h2 {font-size:20px; color: #00B050;}
</style>
<?php
                        echo $this->Html->css('table_css');
?>
<script type="text/javascript">
	jQuery(document).ready(function(){  });
	function active(id){
		jQuery.ajax({
			url : "<?php echo Configure::read('base_url');?>paymentmethods/active/"+id,
			success : function (html) {
				//jQuery("#html_textarea").hide();
				document.getElementById("status"+id).innerHTML = ""; 					
				jQuery("#status"+id).append(html);
				}
		});                
	} 

	function inactive(id){
		jQuery.ajax({
			url : "<?php echo Configure::read('base_url');?>paymentmethods/inactive/"+id,
			success : function (html) {
				document.getElementById("status"+id).innerHTML = ""; 					
				jQuery("#status"+id).append(html);
				}
		});                
	} 
</script>